package cn.edu.hunan.pm.mapper;
import cn.edu.hunan.pm.Entity.PatentTransaction;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PatentTransactionMapper {
    @Insert("INSERT INTO patenttransactions(owner, userName, transactionTime, transactionPrice, patentName) VALUES(#{owner}, #{userName}, #{transactionTime}, #{transactionPrice}, #{patentName})")
    void insert(PatentTransaction patentTransaction);

    @Delete("DELETE FROM patenttransactions WHERE transactionId = #{transactionId}")
    void deleteById(Integer transactionId);

    @Update("UPDATE patenttransactions SET owner = #{owner}, userName = #{userName}, transactionTime = #{transactionTime}, transactionPrice = #{transactionPrice}, patentName = #{patentName} WHERE transactionId = #{transactionId}")
    void update(PatentTransaction patentTransaction);

    @Select("SELECT * FROM patenttransactions WHERE transactionId = #{transactionId}")
    PatentTransaction findById(Integer transactionId);

    @Select("SELECT * FROM patenttransactions")
    List<PatentTransaction> findAll();
}

